package com.itheima.reggin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.itheima.reggin.entity.OrderDetail;
import com.itheima.reggin.entity.Report;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {

    @Select("select if(count(dish_id) is null,0,count(dish_id)) from order_detail where dish_id=#{dishId} group by dish_id")
    Integer saleNum(Long dishId);


//    @Select("select sum(number) from order_detail where setmeal_id=#{setmealId}")
//@Select("select if(count(setmeal_id) is null,0,count(setmeal_id)) from order_detail where setmeal_id=#{setmealId} group by setmeal_id ")
     @Select("SELECT SUM(number) from order_detail where setmeal_id= #{setmealId}")
    Integer saleNums(Long setmealId);


//    @Select("select  name,sum(number) value  from order_detail  group by name order by value desc")
//    List<Report> getNumber();


}
